# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2024/10/26
desc: 
sample: 
"""
import os
import time

import pytest

from utils import zip_folder, send_email_with_attachment_163

if __name__ == '__main__':
    pytest.main()
    #sv日志的详细程度
    #auto配合 xdist并行
    #配置参数可以统一放到pytest.ini
    #pytest.main(['-sv','-n','4','excel的数据驱动Test.py','--clean-alluredir', '--alluredir=allure-results'])
    #自动化生成报告allure serve allure-results
    os.system(r"allure generate -c -o allure-report")
    #time.sleep(30)
    local_time = time.localtime(time.time())
    # 格式化输出
    #attachment_path = r'D:\PycharmProjects\flaskProject\pythonProject_0921_test\mypytest\allure-report'
    attachment_path = os.path.join(os.getcwd(), 'allure-report')
    formatted_time = time.strftime('%Y%m%d_%H%M%S', local_time)
    attachment_zip_path = f'{attachment_path}_{formatted_time}.zip'
    zip_folder(attachment_path, attachment_zip_path)
    sender_email = "testfan2@163.com"
    sender_password = "MSQOTDVQPMKSRZZS"
    receiver_email = "279313259@qq.com" #地址改成你自己的接受邮箱
    subject = "测试邮件"
    body = "这是一封带有附件的测试邮件。"
    send_email_with_attachment_163(sender_email, sender_password, receiver_email, subject, body, attachment_zip_path)



